#ifndef SMOOTHCURVEWIDGET_H
#define SMOOTHCURVEWIDGET_H

#include <QWidget>
#include <qqtcore.h>

class SmoothCurveWidget : public QWidget
{
    Q_OBJECT
public:
    explicit SmoothCurveWidget ( QWidget* parent = nullptr );
    virtual ~SmoothCurveWidget() {}
    /*
     * 设置是否显示点
    */
    void setShowKnots ( bool show = false );
    /*
     * method
     * 0 none
     * 1 gen1
     * 2 gen2
    */
    void setGeneratorMethod ( int method = 2 ) { generatorMethod = method; }
    /*
     * 功能函数
    */
    void generateCurves(); // 生成平滑曲线和非平滑曲线
    QList<QPointF>& getKNotes() { return knots; }
signals:

private slots:

    // QWidget interface
protected:
    virtual void paintEvent ( QPaintEvent* event ) override;

private:
    QList<QPointF> knots;        // 曲线上的点
    QPainterPath smoothCurve1;   // 平滑曲线
    QPainterPath smoothCurve2;   // 平滑曲线
    QPainterPath nonSmoothCurve; // 直接连接点的非平滑曲线

    bool showKnots;
    int generatorMethod ;
};

#endif // SMOOTHCURVEWIDGET_H
